import os, sys
from PyQt5.QtWidgets import QApplication, QWidget, QMessageBox
from PyQt5 import uic

from ui_test.audio_mk import AudioMk


class MyWindow(QWidget):
    def __init__(self):
        super().__init__()
        self.txt_mk_ui = None
        self.ui = None
        self.ui = uic.loadUi(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ui/main.ui'))
        self.aa = AudioMk()
        self.setupUi()
        # print(self.audioMk.ui)

    def setupUi(self):
        self.ui.stackedWidget.removeWidget(self.ui.page_2)
        self.ui.stackedWidget.addWidget(
            uic.loadUi(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ui/txt_mk.ui')))
        # self.ui.stackedWidget.addWidget(
        #     uic.loadUi(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ui/audio_mk.ui')))
        self.ui.stackedWidget.addWidget(self.aa.ui)
        self.ui.stackedWidget.addWidget(
            uic.loadUi(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ui/video_split.ui')))

        self.ui.action_txt_mk.triggered.connect(self.on_txt_mk_triggered)
        self.ui.action_audio_mk.triggered.connect(self.on_audio_mk_triggered)
        self.ui.action_video_split.triggered.connect(self.on_video_split_triggered)

        self.ui.toolButton_txt_mk.clicked.connect(self.on_txt_mk_triggered)
        self.ui.toolButton_audio_mk.clicked.connect(self.on_audio_mk_triggered)
        self.ui.toolButton_video_split.clicked.connect(self.on_video_split_triggered)
        self.ui.toolButton_test.clicked.connect(self.on_test_triggered)

    def on_txt_mk_triggered(self):
        print('txt_mk_triggered')
        self.ui.stackedWidget.setCurrentIndex(1)

    def on_audio_mk_triggered(self):
        self.ui.stackedWidget.setCurrentIndex(2)

    def on_video_split_triggered(self):
        self.ui.stackedWidget.setCurrentIndex(3)

    def on_test_triggered(self):
        self.showMessageBox()

    def showMessageBox(self):
        # 创建并显示提示框
        msg_box = QMessageBox()
        msg_box.setIcon(QMessageBox.Information)
        msg_box.setText("这是一个提示框")
        msg_box.setWindowTitle("提示")
        msg_box.setStandardButtons(QMessageBox.Ok)

        msg_box.exec_()




if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = MyWindow()
    window.ui.show()
    app.exec()
